﻿// code06020201.cpp : 传递参数
// 引用形参，返回多结果

#include <iostream>
#include <string>
using namespace std;
//返回s中c第一次出现的位置索引
string::size_type find_char(const string& str,const char& ch,string::size_type& occurs)
{
	occurs = 0;
	string::size_type occur_first = str.size();
	for (string::size_type i = 0; i != str.size(); ++i)
	{
		if (str[i]==ch)
		{
			++occurs;
			if (occur_first==str.size())
			{
				occur_first = i;
			}
		}
	}
	return occur_first+1;
}


int main()
{
	cout << "输入字符串：" << endl;
	string str;
	string::size_type count = 0;
	while (cin>>str&&!str.empty())
	{
		const auto index = find_char(str, 'c', count);
		if (index==str.size()+1)
		{
			cout << str << "中没有出现'c'" << endl;
		}
		else
		{
			cout << str << "中出现‘c’出现" << count << "次，第一次出现在第" << index << "位上" << endl;
		}
		
	}
	return 0;
}

